using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using UwinEducation.Domain.Entities;

namespace UwinEducation.Infrastructure.Persistence.Configurations
{
    /// <summary>
    /// 订单折扣实体配置
    /// </summary>
    public class OrderDiscountConfiguration : IEntityTypeConfiguration<OrderDiscount>
    {
        public void Configure(EntityTypeBuilder<OrderDiscount> builder)
        {
            // 设置主键
            builder.HasKey(d => d.Id);

            // // 设置外键关系
            // builder.HasOne(d => d.Order)
            //     .WithMany(o => o.OrderDiscounts)
            //     .HasForeignKey(d => d.OrderId)
            //     .OnDelete(DeleteBehavior.ClientSetNull);

            // 设置 Creator 导航属性与 CreatedBy 的关系
            builder.HasOne(d => d.Creator)
                .WithMany()
                .HasForeignKey(d => d.CreatedBy)
                .OnDelete(DeleteBehavior.ClientSetNull);
        }
    }
} 